# -*-encoding: Utf-8 -*-
# @File : hjt_tools.py
# author: HJT
# Time：2024/3/21
import datetime
import inspect

import yaml
import random

from config.settings import ROOT_PATH, cfg


class DebugTalk:
    # 获取基础路径
    def read_config(self, keyword: str):
        try:
            return cfg[keyword]
        except (TypeError, KeyError):
            raise

    def read_extract(self, key: str):
        with open(ROOT_PATH + "/extract.yaml", mode='r', encoding='utf-8', ) as f:
            result = yaml.load(stream=f, Loader=yaml.FullLoader)
        try:
            return result[key]
        except (TypeError, KeyError):
            raise

    # 获取当前时间
    def get_current_time(self, format_="%Y%m%d%H%M%S"):
        current_time = datetime.datetime.now()
        formatted_time = current_time.strftime(format_)
        return formatted_time

    def hjt_rand(self, *args):
        func, *ar = args
        print('aaa', func)
        print(ar)
        if func == 'randint':
            return random.randint(*ar)
        else:
            return None

    def s_upper(self, s: str):
        return s.upper()

    def func(self, l, s, e):
        return l[s:e]

    def func1(self, l, idx):
        return l[idx].items()

    def func2(self, l):
        return str(str(l)[0])


if __name__ == '__main__':
    dk = DebugTalk()
    print(dk.hjt_rand('randint', 1, 109))
